package com.yehongyu.mytools.ui.app;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.LayoutManager;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;

import javax.swing.JPanel;

public class MyPanel extends JPanel {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public static final int MESSAGE_X = 75;
	public static final int MESSAGE_Y = 150;

	public MyPanel() {
		super();
		// TODO Auto-generated constructor stub
	}

	public MyPanel(boolean isDoubleBuffered) {
		super(isDoubleBuffered);
		// TODO Auto-generated constructor stub
	}

	public MyPanel(LayoutManager layout) {
		super(layout);
		// TODO Auto-generated constructor stub
	}

	public MyPanel(LayoutManager layout, boolean isDoubleBuffered) {
		super(layout, isDoubleBuffered);
		// TODO Auto-generated constructor stub
	}
	
	public void paintComponent(Graphics g)
	{
		super.paintComponent(g);
		
		g.drawString("My first panel in my first frame!",MESSAGE_X,MESSAGE_Y);
		g.drawString("Second message is also mine!",MESSAGE_X,MESSAGE_Y+20);
		g.draw3DRect(MESSAGE_X-2, MESSAGE_Y-15, 200, 40, true);
		
		Graphics2D g2 = (Graphics2D) g;
		
		Rectangle2D rect = new Rectangle2D.Double(300,100,200,150);
		g2.draw(rect);
		
		Ellipse2D ellipse = new Ellipse2D.Double();
		ellipse.setFrame(rect);
		g2.draw(ellipse);
		
		g2.draw(new Line2D.Double(300,100,500,250));
		
		double centerX = rect.getCenterX();
		double centerY = rect.getCenterY();
		double radius = 75;
		
		Ellipse2D circle = new Ellipse2D.Double();
		circle.setFrameFromCenter(centerX,centerY,centerX+radius,centerY+radius);
		g2.draw(circle);
		
		g2.setPaint(Color.RED);
		g2.drawString("Warning!",100,100);
		
		g2.setPaint(new Color(0,128,128));
		g2.drawString("Welcome!",75,125);

//		Graphics2D g2 = (Graphics2D)g;
//		Rectangle2D rect = new Rectangle2D();
//		g2.draw(rect);
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
